home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxsync.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.8 KB  |  76 lines

  1. /* Copyright (C) 1998 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxsync.h,v 1.2 2000/09/19 19:00:40 lpd Exp $ */
  20. /* Interface to synchronization primitives */
  21.  
  22. /* Initial version 2/1/98 by John Desrosiers (soho@crl.com) */
  23.  
  24. #if !defined(gxsync_INCLUDED)
  25. #  define gxsync_INCLUDED
  26.  
  27. #include "gpsync.h"
  28. #include "gsmemory.h"
  29.  
  30. /* This module abstracts the platform-specific synchronization primitives. */
  31. /* Since these routines will see heavy use, performance is important. */
  32.  
  33. /* ----- Semaphore interface ----- */
  34. /* These have the usual queued, counting semaphore semantics: at init time, */
  35. /* the event count is set to 0 ('wait' will wait until 1st signal). */
  36. typedef struct gx_semaphore_s {
  37.     gs_memory_t *memory;    /* allocator to free memory */
  38.     gp_semaphore native;    /* MUST BE LAST last since length is undef'd */
  39.     /*  platform-dep impl, len is gp_semaphore_sizeof() */
  40. } gx_semaphore_t;
  41.  
  42. gx_semaphore_t *        /* returns a new semaphore, 0 if error */
  43.     gx_semaphore_alloc(P1(
  44.               gs_memory_t * memory    /* memory allocator to use */
  45.               ));
  46. void
  47.     gx_semaphore_free(P1(
  48.              gx_semaphore_t * sema    /* semaphore to delete */
  49.              ));
  50.  
  51. #define gx_semaphore_wait(sema)  gp_semaphore_wait(&(sema)->native)
  52. #define gx_semaphore_signal(sema)  gp_semaphore_signal(&(sema)->native)
  53.  
  54.  
  55. /* ----- Monitor interface ----- */
  56. /* These have the usual monitor semantics: at init time, */
  57. /* the event count is set to 1 (1st 'enter' succeeds immediately). */
  58. typedef struct gx_monitor_s {
  59.     gs_memory_t *memory;    /* allocator to free memory */
  60.     gp_monitor native;        /* platform-dep impl, len is gp_monitor_sizeof() */
  61. } gx_monitor_t;
  62.  
  63. gx_monitor_t *            /* returns a new monitor, 0 if error */
  64.     gx_monitor_alloc(P1(
  65.             gs_memory_t * memory    /* memory allocator to use */
  66.             ));
  67. void
  68.     gx_monitor_free(P1(
  69.                gx_monitor_t * mon    /* monitor to delete */
  70.                ));
  71.  
  72. #define gx_monitor_enter(sema)  gp_monitor_enter(&(sema)->native)
  73. #define gx_monitor_leave(sema)  gp_monitor_leave(&(sema)->native)
  74.  
  75. #endif /* !defined(gxsync_INCLUDED) */
  76.